from dataclasses import dataclass

from src.application.order.dto.order import OrderDTO
from src.application.order.uow import OrderUoW


@dataclass(frozen=True)
class GetExpiringOrders:
    autorenew: bool


class GetExpiringOrdersHandler:
    """Получаем заканчивающиеся заказы"""

    def __init__(self, *, uow: OrderUoW) -> None:
        self._uow = uow

    async def __call__(self, command: GetExpiringOrders) -> list[OrderDTO]:
        orders = await self._uow.order_reader.get_expiring_orders(command.autorenew)

        return orders
